﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WRSManagementSystem.Models
{
    public class PeopleRepoFake : Model.Repos.IPeopleRepository
    {

        #region IRepository<Person> Members

        public int Count()
        {
            throw new NotImplementedException();
        }

        public int Count(System.Linq.Expressions.Expression<Func<Model.Person, bool>> expression)
        {
            throw new NotImplementedException();
        }

        public void Add(Model.Person entity)
        {
            entity.Id = Guid.NewGuid();
            list.Add(entity);
        }

        public void Remove(Model.Person entity)
        {
            throw new NotImplementedException();
        }

        public void Save(Model.Person entity)
        {
            Model.Person per = list.FirstOrDefault(p => p.Id == entity.Id);
            list.Remove(per);
            list.Add(entity);
        }

        public Model.Person FindOne(Guid id)
        {
            return list.FirstOrDefault(p => p.Id == id);
        }

        public Model.Person FindOne(System.Linq.Expressions.Expression<Func<Model.Person, bool>> expression)
        {
            throw new NotImplementedException();
        }

        public bool TryFindOne(System.Linq.Expressions.Expression<Func<Model.Person, bool>> expression, out Model.Person entity)
        {
            throw new NotImplementedException();
        }

        static List<Model.Person> list = new List<Model.Person>() {
                new Model.Person() { Id= Guid.NewGuid(), Name = "Marian", Surname = "Zawadzki" },
                new Model.Person() { Id= Guid.NewGuid(), Name = "Kubuś", Surname = "Puchatek" },
                new Model.Person() { Id= Guid.NewGuid(), Name = "Jan", Surname = "Kowalski" },
                new Model.Person() { Id= Guid.NewGuid(), Name = "Monar", Surname = "Monarski"}
        };

        public IQueryable<Model.Person> Find()
        {
            return list.AsQueryable<Model.Person>();
        }

        public IQueryable<Model.Person> Find(Guid id)
        {
            throw new NotImplementedException();
        }

        public IQueryable<Model.Person> Find(System.Linq.Expressions.Expression<Func<Model.Person, bool>> expression)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}